<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue基础模板</title>
    <script src="../vue.js"></script>
</head>

<body>
    <div id="app">
       <button @click="person.age++">修改年龄</button>
       <button @click="person.name='yuexia'">改变姓名</button>
       <button @click="addAttr">添加性别</button>
       <button @click="deleteAttr">删除属性</button>
       <h2>{{person.age}}</h2>
       <h2>{{person.name}}</h2>
       <h2>{{person.sex}}</h2>
    </div>

    <script>
        Vue.config.productionTip = false;
        const vm = new Vue({
            el: "#app",
            data() {
                return {
                    person:{
                        name:'xuyue',
                        age:18
                    }
                }
            },
            methods:{
                addAttr(){
                    this.$set(this.person,'sex','男')
                },
                deleteAttr(){
                    this.$delete(this.person,'sex')
                    this.$delete(this.person,'name')
                }
            }
        })
    </script>
</body>

</html>